package com.zekdot.registerclient.service.mq;

import com.alibaba.fastjson.JSONObject;
import com.zekdot.registerclient.dao.EnrollDataDao;
import com.zekdot.registerclient.entity.EnrollDataEntity;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Create by zekdot on 20-4-12.
 */
@Component
public class UpdateReciver {
    @Resource
    private EnrollDataDao enrollDataDao;
    @RabbitHandler
    @RabbitListener(queues = "UpdateQueue")
    public void process(List<Object> req){
        // 第一个是报名id
        String eId = (String) req.get(0);
        // 第二个是用户名列表
        List<Map<String,Object>> reqs = (List<Map<String, Object>>) req.get(1);
        if(reqs.size() == 0)
            return ;
//        System.out.println(reqs);
        // 实际更新
        enrollDataDao.batchUpdateStatus(eId,reqs);
    }
}
